import sqlite3


def opendb():
    dbpath = './db/Course.db'
    conn = sqlite3.connect(dbpath)
    return conn


def closedb(coon):
    coon.close()


def excutesql(sql):
    conn = opendb()
    cur = conn.cursor()
    cur.execute(sql)
    fields = []

    for field in cur.description:
        fields.append(field[0])

    result = cur.fetchall()
    cur.close()
    closedb(conn)
    return fields, result

def updatedb(sql):
    conn=opendb()
    cusor = conn.cursor()
    cusor.execute(sql)
    conn.commit()
    closedb(conn)


